import Dao.BookDao;
import Service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AppForLifeCycle {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
//        设置关闭钩子
        ctx.registerShutdownHook();
        BookDao bookDao = ctx.getBean("bookDao", BookDao.class);
        bookDao.save();
//        ClassPathXmlApplicationContext有close函数
//        ctx.close();

    }
}
